<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "artcile".
 *
 * @property string $id ID
 * @property string $title 标题
 * @property string $content 文章类容
 * @property int $status 状态
 * @property int $member_id 用户ID
 * @property int $create_time 创建时间
 */
class Artcile extends \yii\db\ActiveRecord
{

    const STATUS_START= 1; //待取件
    const STATUS_INIT = 2; //取件
    const STATUS_EXAMINE = 3; //签收

    public static $status=[
        self::STATUS_START=>'草搞',
        self::STATUS_INIT=>'发布',
        self::STATUS_EXAMINE=>'归档'
    ];
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'artcile';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['title','content','member_id','status'],'required'],
            [['content'], 'string'],
            [['status', 'member_id', 'create_time'], 'integer'],
            [['title'], 'string', 'max' => 255],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'title' => '标题',
            'content' => '文章类容',
            'status' => '状态',
            'member_id' => '作者',
            'create_time' => '创建时间',
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getName0()
    {
        return $this->hasOne(Member::class,['id'=>'member_id']);
    }

    public function getStatus0()
    {
        return $this->hasOne(PostStatus::class,['id'=>'status']);
    }
}
